<template>
	<div :class="$hasEditPermission('/BHView') && tableItemData != 'no Data' ? '' : 'maskDisabled1'">
		<div class="tabs-cps-view"
			:class="$hasEditPermission('/BHView') && tableItemData != 'no Data' ? '' : 'maskDisabled2'">
			<div class="title">
				<div class="item">
					<div class="label">定点名称</div>
					<div class="flex-ipt-view">
						<el-input v-model="tableItemData.POS_ORDR" class="ipt yellow mini-ipt" readonly></el-input>
						<el-input v-model="tableItemData.POS_NAME" class="ipt yellow small-ipt" readonly
							style="margin-left: 8px"></el-input>
						<el-button size="mini" style="width: 24px !important;" @click="onUpArrowClick(0)"><i
								class="el-icon-caret-top"></i></el-button>
						<el-button size="mini" style="width: 24px !important;" @click="onUpArrowClick(1)"><i
								class="el-icon-caret-bottom"></i></el-button>
					</div>
				</div>
				<div>
					<span>測定日</span>
					<el-select v-model="tempDateSelect" class="mini-select" placeholder=" "
						@change="selectChgDateOption" :disabled="addDate != '' || tableItemData == 'no Data'">
						<el-option v-for="item in comboxList.tempDate" :key="item" :label="item" :value="item">
						</el-option>
					</el-select>
					<!-- <el-button type="mini">追加</el-button> -->

					<el-button v-show="$hasEditPermission('/BHView')" class="hide_input" size="mini"
						:disabled="tableItemData == 'no Data'"
						:style="{ height: '24px', background: addDate != '' ? '#bc000f' : '', color: addDate != '' ? 'white' : '', borderColor: addDate != '' ? '#bc000f' : '' }"
						:type="addDate != '' ? 'default' : ''">追加
						<el-date-picker @change="_changeAddDate" v-model="addDate" value-format="yyyy-MM-dd"
							placeholder=" " class="ipt picker">
						</el-date-picker>
					</el-button>

				</div>
			</div>
			<ux-grid ref="singleTable" :data="prposTabelData" style="width: 100%; margin-bottom: 12px"
				:header-cell-style="{
					color: 'rgba(0, 0, 0, 0.85)',
					fontSize: '14px',
					textAlign: 'left',
					fontWeight: 'bold',
					padding: 0,
					height: '32px',
				}" :row-style="{
					color: 'rgba(96,98,102,1)',
					fontSize: '13px',
					textAlign: 'left',
					padding: 0,
					height: '32px',
				}" :cell-style="cellStyle" @current-change="handleCurrentChange" highlight-current-row :height="tableHeight"
				element-loading-spinner="el-icon-loading" element-loading-background="#f8f8f8"
				:element-loading-text="$t('message.bhView.loading')">
				<template slot="empty"> No data </template>
				<ux-table-column property="index" title="No." align="center" width="50">

					<template slot-scope="scope">
						<p style="text-align: center;">{{ scope.row.id }}</p>
					</template>
				</ux-table-column>
				<ux-table-column property="name" title="方位名称" align="center" width="110">

					<template slot-scope="scope">
						<p class="tabYellow">{{ scope.row.msrPnt }}</p>
					</template>
				</ux-table-column>

				<ux-table-column property="name" title="測定値" align="center" width="110">

					<template slot-scope="scope">
						<el-input class="table-input" v-model="scope.row.aThck"
							@input="scope.row.aThck = $setMyNum(scope.row.aThck, '4 - 2')"></el-input>
					</template>
				</ux-table-column>

				<ux-table-column property="name" title="参考値" align="center" width="70">

					<template slot-scope="scope">
						<!-- <el-checkbox v-model="checked"></el-checkbox> -->
						<el-image @click="scope.row.crrcalFlg = scope.row.crrcalFlg == 1 ? 0 : 1"
							style="width: 17px;height: 17px;padding: 2px;margin-top: 3px;cursor: pointer;left: 50%;transform: translateX(-50%);"
							:src="scope.row.crrcalFlg == 1 ? checkImg : uncheckImg" fit="fill"></el-image>
					</template>
				</ux-table-column>

				<ux-table-column property="name" title="検査メモ" align="center">

					<template slot-scope="scope">
						<p class="tabYellow">{{ scope.row.note }}</p>
					</template>
				</ux-table-column>

				<ux-table-column property="name" title="取替" align="center" width="60">

					<template slot-scope="scope">
						<!-- <el-checkbox v-model="checked"></el-checkbox>  chgDate -->
						<p class="tabYellow">
							<el-image
								style="width: 17px;height: 17px;padding: 2px;margin-top: 3px;left: 50%;transform: translateX(-50%);"
								:src="scope.row.chgDateFlag == 1 ? checkImg : uncheckImg" fit="fill"></el-image>
						</p>

					</template>
				</ux-table-column>

				<ux-table-column property="name" title="取替後肉厚" align="center" width="110">

					<template slot-scope="scope">
						<el-input class="table-input-center" style="text-align: center;" v-model="scope.row.sThck"
							@input="scope.row.sThck = $setMyNum(scope.row.sThck, '4 - 2')"
							:disabled="scope.row.chgDateFlag == 1 ? false : true"></el-input>
					</template>
				</ux-table-column>
			</ux-grid>

			<div class="sco">
				<div class="row">
					<div class="item">
						<div class="label">測定状況</div>
						<el-select v-model="prposTabelSelectData.tempCode" class="ipt" placeholder=" ">
							<el-option v-for="item in comboxList.temp" :key="item.key" :label="item.label"
								:value="item.key">
							</el-option>
						</el-select>
					</div>
					<div class="item">
						<div class="label">検査方法</div>
						<el-select v-model="prposTabelSelectData.ispWayType" class="ipt" placeholder=" ">
							<el-option v-for="item in comboxList.ispMet" :key="item.key" :label="item.label"
								:value="item.key">
							</el-option>
						</el-select>
					</div>
				</div>

				<div class="row">
					<div class="item long-item">
						<div class="label">検査メモ</div>
						<el-input v-model="prposTabelSelectData.note" class="long-ipt ipt" placeholder=" "
							@input="prposTabelSelectData.note = $setMaxLength(prposTabelSelectData.note, 100)"></el-input>
					</div>
				</div>

				<div class="row">
					<div class=" last-item">
						<div class="flex-item" style="display: flex;cursor: pointer;" @click="changeFn">
							<el-image
								style="width: 17px;height: 17px;cursor: pointer;display: flex;align-items: center; margin: 0 8px 0 0;"
								:src="prposTabelSelectData.chgDateFlag == 1 ? checkImg : uncheckImg"
								fit="fill"></el-image>
							<!-- <el-checkbox v-model="prposTabelSelectData.chgDateFlag == 1">取替</el-checkbox> -->
							<span>取替</span>
						</div>
						<!-- <div class="flex-item">
					<el-image @click="scope.row.crrcalFlg = scope.row.crrcalFlg == 1 ? 0 : 1"
						style="width: 17px;height: 17px;padding: 2px;margin-top: 3px;cursor: pointer;"
						:src="scope.row.crrcalFlg == 1 ? checkImg : uncheckImg" fit="fill"></el-image>
					<el-checkbox @click="prposTabelSelectData.chgDateFlag = prposTabelSelectData.chgDateFlag == '0'?1:0"
						v-model="prposTabelSelectData.chgDateFlag">取替</el-checkbox>
				</div> -->
						<div class="flex-item">
							<span>取替日</span>
							<!-- <el-select v-model="ChgDate" class="mini-select" placeholder=" " @change="selectChgDate"> -->
							<!-- <el-option v-for="item in comboxList.tempDate" :key="item" :label="item" :value="item">
						</el-option> -->
							<el-date-picker @change="selectChgDate" v-model="ChgDate" value-format="yyyy-MM-dd"
								placeholder=" " class="picker"
								:class="prposTabelSelectData.chgDateFlag != 1 ? '' : addDate != '' ? 'orange' : 'tabYellow'"
								:disabled="(addDate == '' && selectChgDate) || prposTabelSelectData.chgDateFlag != 1">
							</el-date-picker>
							<!-- </el-select> -->

						</div>
						<div class="last-box">
							<div>
								<span class="">公称値</span>
								<el-input v-model="prposTabelSelectData.orgThck" class="long-ipt ipt yellow"
									placeholder=" " disabled
									@input="prposTabelSelectData.orgThck = $setMyNum(prposTabelSelectData.orgThck, '4 - 2')"></el-input>
								<span>[mm]</span>
							</div>
							<div class="t10">
								<span class="">管理値</span>
								<el-input v-model="prposTabelSelectData.mgtThck" class="long-ipt ipt yellow"
									placeholder=" " disabled
									@input="prposTabelSelectData.mgtThck = $setMyNum(prposTabelSelectData.mgtThck, '4 - 2')"></el-input>
								<span>[mm]</span>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="item">
						<div class="label">検査員</div>
						<el-input v-model="Aco.accOpeMemb"
							@input="Aco.accOpeMemb = $setMaxLength(Aco.accOpeMemb, '240')" class="ipt" placeholder=" ">

						</el-input>
					</div>
					<div class="item">
						<div class="label">計測器</div>
						<el-input v-model="Aco.accOpeMemo"
							@input="Aco.accOpeMemo = $setMaxLength(Aco.accOpeMemo, '240')" class="ipt" placeholder=" ">

						</el-input>
					</div>
				</div>
				<div class="row"
					style="  width: 100%;display: flex;align-items: center; justify-content: space-between;">
					<span></span>
					<p class="r-describe">
						<el-button class="black-btn1" @click="isShow = true">
							<span>フォルダーを開く</span>
						</el-button>
						<el-button class="black-btn1" @click="isUpShow = true">
							<i class="iconfont" style="font-size:16px;">&#xe825;</i>
							<span>アップロード</span>
						</el-button>
						<el-button type="default" size="mini" @click="downLoadFn"><i class="iconfont"
								style="font-size: 20px;"></i>ダウンロード</el-button>
						<el-button class="black-btn1" @click="delFn" :disabled="!Aco.accOpeFile">
							削除
						</el-button>
					</p>
				</div>
				<div class="row">
					<div class="item long-item">
						<div class="label">添付資料</div>
						<el-input v-model="Aco.accOpeFile" class="long-ipt ipt yellow" placeholder=" "
							readonly></el-input>
					</div>
				</div>


				<tabFiveTabelShow v-if="isShow" type="rouHou" title="報告書フォルダ" @close="isShow = false"
					@getResponse="getResponse">
				</tabFiveTabelShow>
				<ImportDialogForPic v-if="isUpShow" :_api="api" @close="isUpShow = false" :title="title"
					@getResponse="getResponse" :type="2">
				</ImportDialogForPic>
			</div>

		</div>
	</div>
</template>

<script>
import $ from "jquery";
import {
	getThckDeterResCombox, getThckDeterRes,
	addThckDeterResVerifyA, addThckDeterResVerifyB,
	GetThckDeterResTipsMsg, AddThckDeterResVerify,
	AddThckDeterRes, getThckDeterminator, UpdThckDeterminator, delThckDeterminatorTipsMsg
} from "@/api/api";
import eventBus from "@/eventBus/bus";
import { getLocalStorage } from "@/utils/storage";
import { cloneDeep, isEqual } from 'lodash-es';
import { showLoading, hideLoading } from "@/utils/loading";
import tabFiveTabelShow from '@/components/TabelLineCadViews/BSDetailConmpontents/tabFiveTabelShow.vue'
import ImportDialogForPic from '@/components/Excel/ImportDialog/ImportDialogForPic.vue';
import _ from 'lodash-es';
export default {
	name: "Tab_4",
	data() {
		return {
			isShow: false,
			isUpShow: false,
			api: '/api/Thck/upLoadThckDeterminatorAssFile',
			title: this.$t("message.BSCps.tabs.label_5"),
			userData: getLocalStorage('userData'),
			checkImg: require("@/assets/img/checkbox_sel.png"),
			uncheckImg: require("@/assets/img/checkbox_unsel.png"),
			prposTabelData: [
				// { index: 1, name: "3-2" },
				// { index: 2, name: "3-2" },
				// { index: 3, name: "3-2" },
				// { index: 4, name: "3-2" },
				// { index: 5, name: "3-2" },
				// { index: 6, name: "3-2" },
				// { index: 7, name: "3-2" },
			],
			tableHeight: 250,
			loading: false,
			optionsValue: "",
			value: "",
			options: [],
			checked: true,

			prposTabelSelectData: {},
			tempDateSelect: "",
			// 下拉数据
			comboxList: {
				ispMet: [], // 1.建设年月
				temp: [],
				tempDate: [],
				temp_Date: '',
			},

			addDate: '',
			ChgDate: '',
			tempSelectData: {},
			Aco: {
				accOpeFile: '',
				accOpeMemb: '',
				accOpeMemo: '',
			},
			AcoClone: {
				accOpeFile: '',
				accOpeMemb: '',
				accOpeMemo: '',
			},
			ExcuType: 1,
			tempE: ''

		};
	},
	components: {
		tabFiveTabelShow, ImportDialogForPic
	},
	props: ["tableItemData"],

	watch: {
		//table数据
		tableItemData(nVal) {
			this.addDate = '';
			if (nVal == 'no Data') {
				// this.prposTabelData = [];
				this.prposTabelData.forEach(item => {
					item.tempCode = '';
					item.aThck = '';
					item.sThck = '';
					item.ispWayType = '';
					item.note = '';
					item.chgDateFlag = 0;
					item.crrcalFlg = 0;
				})

				setTimeout(() => {
					this.$emit("DataChangeFn", false);
				}, 500);
			} else {
				this.getThckDeterResComboxApi();
			}
		},
		// '$store.state.isStop.name': function (nVal, oVal) {
		//你需要执行的代码
		// 	console.log(nVal, oVal);
		// 	if (nVal == 'active') {
		// 		this.AddThckDeterResApi();
		// 	}
		// },
		prposTabelSelectData: {
			handler(nVal) {
				// 比较选择的数据是否有变化=》是否已经修改东西
				console.log('肉厚测定结果', this.tempSelectData, nVal);
				console.log(isEqual(this.tempSelectData, nVal));

				this.prposTabelData.forEach(item => {
					item.chgDateFlag = nVal.chgDateFlag;
				})

				this.$emit("DataChangeFn", !_.isEqual(this.tempSelectData, nVal));
			},
			deep: true,
		},
		Aco: {
			handler(nVal, oval) {
				// 比较选择的数据是否有变化=》是否已经修改东西
				console.log('肉厚测定结果', this.AcoClone, nVal);
				this.$emit("DataChangeFn", !_.isEqual(nVal, this.AcoClone));
			},
			deep: true,
		},
		prposTabelData: {
			handler(nVal) {
				// 比较选择的数据是否有变化=》是否已经修改东西
				// this.prposTabelData.forEach(item => {
				// 	if (item.aThck != '') {
				// this.$emit('change_D', this.prposTabelData.every(item => !item.aThck) && this.addDate != '')
				// 	}
				// })
			},
			deep: true,
			immediate: true,
		}
	},
	computed: {
	},
	methods: {
		downLoadFn() {
			if (this.Aco.downFilePath) {
				let str = this.Aco.downFilePath;
				let parts = str.split('\\');
				let fileName = parts.pop(); // 获取并移除数组的最后一个元素  
				this.$downFileByBlob({ path: this.Aco.downFilePath, isDown: true, fileName, isOpenNewBlank: false })
			}
		},
		async delFn() {
			let R = await delThckDeterminatorTipsMsg({})
			this.$confirm(R.data.msg, '', {
				confirmButtonText: 'OK',
				cancelButtonText: 'Cancel',
				type: 'warning'
			}).then(async () => {
				// this.Aco = {
				// 	accOpeFile: '',
				// 	accOpeMemb: '',
				// 	accOpeMemo: '',
				// }
				this.Aco.accOpeFile = '';
			}).catch(() => {
			});
		},
		async UpdThckDeterminatorFn() {
			let D = {
				dmgCode: this.$store.state.macCode,
				IspDate: this.tempDateSelect,
				Account: getLocalStorage("userName"),
				...this.Aco
			}
			await UpdThckDeterminator(D);
		},
		getResponse(arr) {
			// this.$message.success("OK");
			arr.forEach(item => {
				this.Aco.accOpeFile = item.showPath || item.name;
			})
		},
		changeFn() {
			console.log(this.prposTabelSelectData.chgDateFlag);
			this.prposTabelSelectData.chgDateFlag = this.prposTabelSelectData.chgDateFlag == '0' ? 1 : 0;
			this.prposTabelSelectData.DataReplaceFlg = this.prposTabelSelectData.chgDateFlag;
			if (this.prposTabelSelectData.chgDateFlag == 1) {
				this.ChgDate = this.tempDateSelect;
			} else {
				// this.prposTabelSelectData.sThck = '';
			}
		},
		_changeAddDate(e) {
			this.tempE = e;
			let dataJson = {
				dmgCode: this.$store.state.macCode,
				PosNo: Number(this.tableItemData.POS_NO),
				IspDate: e,
			};
			addThckDeterResVerifyA(dataJson).then(res => {
				if (!res || res.data.code == 452) {
					this.addDate = '';

					return
				}
			});
			// 修改日期验证是否可行=>452为统一拦截


			//	初始监听状态---先不需要
			eventBus.$emit('getBasicStyleCompontensCurrent_EventBus');	//	基本仕样

			let Fn = () => {

				let qq = "ssqcop";
				this.prposTabelData.forEach(item => {
					item.tempCode = '';
					item.aThck = '';
					item.sThck = '';
					item.ispWayType = '';
					item.note = '';
					item.chgDateFlag = 0;
					item.crrcalFlg = 0;
				})

				this.ChgDate = '';
				let tempFliterArr = this.comboxList.tempDate.filter(i => i == this.addDate);
				if (tempFliterArr.length == 0) {//新增
					this.tempDateSelect = e;
					this.ExcuType = 2;
					this.selectChgDateOption(e, false);

				} else {//跳到指定日期
					let dataJSon = { code: 2 };
					GetThckDeterResTipsMsg(dataJSon).then(res => {
						this.$alert(res.data.data, '', {
							confirmButtonText: 'OK',
							type: 'warning',
							callback: action => {
								this.ChgDate = '';
							}
						});
						this.selectChgDateOption(e, false);
						this.tempDateSelect = e;
						this.addDate = '';
					});
				}
			}
			/**
			 * 2。  记录当前函数。
			 */
			if (this.$store.state.isCurrentNext) {
				Fn();
			} else {
				/**
				  * 4-1。   记录原来该运行的函数。
				  * 4-2。   执行保存弹出框操作。   
				  */
				this.$store.commit("changeIsCurrentFn", Fn);

				eventBus.$emit('EventBusBasicStyleCompontensSaveFn');	//	基本仕样
			}

		},
		//新增
		async AddThckDeterResApi(isSaveBtn) {

			let msg = await this.GetThckDeterResTipsMsgApi(1);
			this.$confirm(msg, '', {
				confirmButtonText: 'OK',
				cancelButtonText: 'Cancel',
				type: 'warning'
			}).then(async () => {
				this.$emit("isConfirmingFn", false)
				let thckDeterResList = [];
				try {
					this.prposTabelData.forEach(item => {
						thckDeterResList.push(
							{
								PosNo: Number(item.posNo),				//	是	int	posNo 数据列表内的posNo
								RevNo: Number(item.revNo),				//	是	int	修订号 数据列表内的revNo
								Thck: item.aThck == '' || item.aThck == null ? null : Number(item.aThck),				//	是	decimal	测定值 （6）
								ClsType: Number(item.clsType),				//	是	int	方位番号 数据列表内的clsType
								Note: item.note ? item.note.toString() : '',		//	是	string	検査メモ (8)
								// DataReplaceFlg: Number(item.DataReplaceFlg),			//	是	int	数据-取替标识 0=未选中 1=已选中 (83)？？？
								DataReplaceFlg: Number(this.prposTabelSelectData.chgDateFlag),			//	是	int	数据-取替标识 0=未选中 1=已选中 (83)？？？
								OldDataReplaceFlg: Number(item.OldDataReplaceFlg),			//	是	int	数据-取替标识 0=未选中 1=已选中 (83)？？？
								ReplaceFlgThck: item.sThck ? item.sThck.toString() : '',	//	是	string	取替後肉厚 (10)
								ReferenceValCheck: Number(item.crrcalFlg),		//	是	int	参考值 （7） 0=未选中 1=选中
								TempCode: isNaN(item.tempCode) ? Number(this.comboxList.temp.filter(aa => aa.label == item.tempCode)[0].key) :
									Number(item.tempCode),				//	是	int	测定状況 (11)
								IspWayType: isNaN(item.ispWayType) ? Number(this.comboxList.ispMet.filter(aa => aa.label == item.ispWayType)[0].key) :
									Number(item.ispWayType),				//	是	int	测定状況 (11)
								TxtReplaceFlg: Number(this.prposTabelSelectData.chgDateFlag),			//	是	int	页面-取替标识 0=未选中 1=已选中 (14)？？？
								// IspWayType: Number(item.ispWayType) || 0,				//	是	int	検査方法 (12)

								dmgCode: this.$store.state.macCode,
								IspDate: this.tempDateSelect,
								...this.Aco
							}
						)
					})
				} catch (error) {
					// console.log(error);
				}
				// return
				let dataJson = {
					// ExcuType: this.addDate == '' ? 1 : 2,			//	是	int	处理方式 1=编辑 2=新增
					ExcuType: this.ExcuType,			//	是	int	处理方式 1=编辑 2=新增
					PltCode: this.$store.state.pltCode,				//	是	int	装置Code
					Account: getLocalStorage("userName"),				//	是	string	登录 账号
					DmgCode: this.$store.state.macCode,				//	是	int	设备编号
					IspDate: this.tempDateSelect,				//	是	int	测定日 （3）？？？


					ChgDate: this.ChgDate,				//	是	string	取替日 (15)？？？
					thckDeterResList
				}

				// return
				let res1 = await AddThckDeterResVerify(dataJson);

				if (!res1) {
					//  导航条误
					eventBus.$emit('isNavChangeErrorFn');
					//  搜索框索引误
					eventBus.$emit('backParamsForLeftView');
					this.addDate = '';
					this.$alert(res1.data.msg, '', {
						confirmButtonText: 'OK',
						type: 'warning',
					});

					return
				}
				// return
				// ExcuType: this.addDate == '' ? 1 : 2,			//	是	int	处理方式 1=编辑 2=新增
				//	【取替后取替後肉厚】为必填，请填写	
				let aThckFlg = false;
				for (let item = 0; item < this.prposTabelData.length; item++) {
					if (this.prposTabelData[item].chgDateFlag == 1 && !this.prposTabelData[item].sThck && this.addDate != '') {
						let msg = await this.GetThckDeterResTipsMsgApi(4);
						//  导航条误
						eventBus.$emit('isNavChangeErrorFn');
						//  搜索框索引误
						eventBus.$emit('backParamsForLeftView');

						this.$alert(msg, '', {
							confirmButtonText: 'OK',
							type: 'warning',
						});
						return
					}

					// 	// 【测定值】为必填项目，请填写				

					if (this.prposTabelData[item].aThck) {
						aThckFlg = true;

					}
				}
				// if (!aThckFlg && this.addDate != '') {
				if (!aThckFlg && this.ExcuType != 1) {
					let msg = await this.GetThckDeterResTipsMsgApi(6);

					//  导航条误
					eventBus.$emit('isNavChangeErrorFn');
					//  搜索框索引误
					eventBus.$emit('backParamsForLeftView');

					this.$alert(msg, '', {
						confirmButtonText: 'OK',
						type: 'warning',
					});
					return
				}
				showLoading();
				let res = await AddThckDeterRes(dataJson);
				// await this.UpdThckDeterminatorFn();
				console.log(res.data);
				if (res.data.code != 0) {
					hideLoading();

					//  导航条误
					eventBus.$emit('isNavChangeErrorFn');
					//  搜索框索引误
					eventBus.$emit('backParamsForLeftView');

					this.$alert(res.data.msg, '', {
						confirmButtonText: 'OK',
						type: 'warning',
					});


					return
				}

				try {
					var tempFn = null;
					tempFn = this.$store.state.isCurrentFn.toString();
				} catch (error) {
					//
				}

				// 更新成功后的操作
				this.$message.success(
					res.data.msg
				);
				hideLoading();


				/**
				 * new
				 */
				//	刷新？
				this.$store.state.isCurrentNext = true;
				this.addDate = '';
				this.getThckDeterResComboxApi();
				eventBus.$emit('LoadTabelData', true);
				//	追加？
				if (tempFn.indexOf('ssqcop') != -1) {
					setTimeout(() => {
						this.$store.state.isCurrentNext = true;
						this.prposTabelData.forEach(item => {
							item.tempCode = '';
							item.aThck = '';
							item.sThck = '';
							item.ispWayType = '';
							item.note = '';
							item.chgDateFlag = 0;
							item.crrcalFlg = 0;
						})
						this.addDate = this.tempE;
						this.tempDateSelect = this.addDate;
						this.ExcuType = 2;
					}, 2000);
				}
				//	跳转？
				else if (!isSaveBtn) {
					this.$store.state.isCurrentFn()
					this.$store.commit("reSetIsCurrent");
				}
				return

				if (isSaveBtn) {
					this.addDate = '';
					this.getThckDeterResComboxApi();
					eventBus.$emit('LoadTabelData', true);
					return
				}
				// if (tempFn.indexOf('ssqcop') != -1) {
				// eventBus.$emit('LoadTabelData', true);
				// }
				setTimeout(async () => {
					//	追加状态

					if (tempFn.indexOf('ssqcop') != -1) {
						this.$store.state.isCurrentNext = true;
						this.prposTabelData.forEach(item => {
							item.tempCode = '';
							item.aThck = '';
							item.sThck = '';
							item.ispWayType = '';
							item.note = '';
							item.chgDateFlag = 0;
							item.crrcalFlg = 0;
						})
						this.tempDateSelect = this.addDate;
						this.ExcuType = 2;
						return
					}

					this.$store.state.isCurrentFn()

					this.$store.commit("reSetIsCurrent");

					eventBus.$emit('LoadTabelData', true);
				}, 2000);

			}).catch(() => {
				try {
					var tempFn = null;
					tempFn = this.$store.state.isCurrentFn.toString();
				} catch (error) {
					//
				}
				if (isSaveBtn) {
					this.$emit("isConfirmingFn", false)
					return
				}

				this.$store.state.isCurrentNext = true;
				this.addDate = '';
				this.getThckDeterResComboxApi();
				eventBus.$emit('LoadTabelData', true);

				if (tempFn.indexOf('ssqcop') != -1) {
					setTimeout(() => {
						this.addDate = this.tempE;
						this.$store.state.isCurrentFn();
						this.$store.commit("reSetIsCurrent");
						this.$emit("isConfirmingFn", false)
					}, 2000);
				}
			});
		},
		//新增前验证
		async AddThckDeterResVerifyApi() {

		},
		/**
		 * 获取提示信息
		 * code 1 是否保存变更内容		
		 * code 91 指定年度已存在，请在年度一览内选择
		 * code 155 指日期在检査当年度以外		
		 * code 918 【取替后初回值】为必填，请填写	
		 * code 610 输入数据不対，取替后初回值必须大于0		
		 * code 918 【测定值】为必填项目，请填写		
		 * code 610 输入数据不対，测定值必须大于0		
		 */
		async GetThckDeterResTipsMsgApi(code) {
			let dataJSon = { code };
			let res = await GetThckDeterResTipsMsg(dataJSon);
			console.log(res);
			if (res.data.code == 0) {
				return res.data.data;
			}
		},
		//table样式颜色
		cellStyle({ row, column, rowIndex, columnIndex }) {
			let style = {
				color: 'rgba(96,98,102,1)',
				fontSize: '14px',
				textAlign: 'left',
				padding: 0,
				height: '32px',
			};
			if (column.title == '方位名称' || column.title == '検直メモ' || column.title == '取替') {
				style.background = '#ffffe1';
				style.border = "0.1px solid rgb(233, 233, 233)";
				style.transform = 'translateY(-1px)';
			}
			return style;
		},
		//測定日切换
		selectChgDateOption(e, isShowSave = true) {

			//初始监听状态
			if (isShowSave) {
				eventBus.$emit('getBasicStyleCompontensCurrent_EventBus');	//	基本仕样
			}

			let Fn = () => {
				this.temp_Date = e;
				this.ChgDate = e;
				this.getThckDeterResApi();
				this.GetBookRelaAssFileApi();
			}
			/**
			 * 2。  记录当前函数。
			 */
			if (this.$store.state.isCurrentNext) {
				Fn();
			} else {
				/**
				  * 4-1。   记录原来该运行的函数。
				  * 4-2。   执行保存弹出框操作。   
				  */
				this.$store.commit("changeIsCurrentFn", Fn);

				eventBus.$emit('EventBusBasicStyleCompontensSaveFn');	//	基本仕样
			}

		},
		//取替日切换
		async selectChgDate(e) {
			if (!this.ChgDate) {
				return
			}
			// 修改日期验证是否可行
			let dataJson = {
				dmgCode: this.$store.state.macCode,
				PosNo: Number(this.tableItemData.POS_ORDR),
				TxtReplaceFlg: Number(this.prposTabelSelectData.chgDateFlag) || 0,
				DataReplaceFlg: Number(this.prposTabelSelectData.chgDateFlag) || 0,
				OldDataReplaceFlg: Number(this.prposTabelSelectData.OldDataReplaceFlg),
				ChgDate: this.ChgDate,
			};
			let res = await addThckDeterResVerifyB(dataJson);
			if (!res || res.data.code == 452) {
				this.ChgDate = this.tempDateSelect
				return
			}
		},
		//table切换
		handleCurrentChange(val) {
			console.log(val, '列表数据')
			this.prposTabelSelectData = val;

			// this.prposTabelSelectData.tempCode = '2';
			// this.prposTabelSelectData.ispWayType = '2';
			// this.prposTabelSelectData.note = '222'
			//対应key=》label
			if (this.prposTabelSelectData.tempCode) {
				let aa = this.comboxList.temp.filter(i => i.key == this.prposTabelSelectData.tempCode)
				this.prposTabelSelectData.tempCode = aa[0].label
			}
			if (this.prposTabelSelectData.ispWayType) {
				let aa = this.comboxList.ispMet.filter(i => i.key == this.prposTabelSelectData.ispWayType)
				this.prposTabelSelectData.ispWayType = aa[0].label
			}
			this.tempSelectData = cloneDeep(this.prposTabelSelectData);
			this.$forceUpdate();
		},
		//获取下拉框
		getThckDeterResComboxApi() {
			this.prposTabelData = [];
			// this.tempDateSelect = ""; 
			getThckDeterResCombox({
				dmgCode: this.$store.state.macCode,
			}).then((res) => {
				if (res.data.code != 0) {
					return;
				}
				for (let key in this.comboxList) {
					this.comboxList[key] = res.data.data[key];
				}
				// if (this.temp_Date != '') {
				// 	this.tempDateSelect = this.temp_Date;
				// } else {
				if (!this.tempDateSelect) {
					this.tempDateSelect = this.comboxList.tempDate[0];

				}
				// }
				this.ChgDate = this.tempDateSelect;
				console.log(this.tempDateSelect, "下拉框")
				this.getThckDeterResApi();
				this.GetBookRelaAssFileApi();

			});
		},
		//获取列表数据
		getThckDeterResApi() {
			this.prposTabelData = [];
			this.ExcuType = 1;
			this.$emit('DataChangeFn', false);
			console.log('this.tableItemData.POS_ORDR', this.tableItemData.POS_ORDR, this.tempDateSelect);
			if (!Number(this.tableItemData.POS_ORDR) && this.tempDateSelect) {
				return
			}
			getThckDeterRes({
				dmgCode: this.$store.state.macCode,
				posNo: Number(this.tableItemData.POS_NO),
				chgDate: this.tempDateSelect,
			}).then((res) => {

				if (res.data.code != 0) {
					this.prposTabelData = [];
					Object.keys(this.prposTabelSelectData).forEach(key => {
						this.prposTabelSelectData[key] = ''
					})
					setTimeout(() => {
						this.$emit('DataChangeFn', false);
					}, 100);
					return;
				}
				this.prposTabelData = res.data.data;
				this.prposTabelData.forEach((i, v) => {
					i.id = v + 1;
					i.DataReplaceFlg = i.chgDateFlag;
					i.OldDataReplaceFlg = i.chgDateFlag;
				})
				this.$refs.singleTable.setCurrentRow(this.prposTabelData[0]);
				this.prposTabelSelectData = this.prposTabelData[0];
				this.tempSelectData = cloneDeep(this.prposTabelData[0]);
				console.log(this.prposTabelSelectData, "列表数据")
			});
		},
		async GetBookRelaAssFileApi() {
			this.$emit('DataChangeFn', false);
			if (!this.tempDateSelect) {
				return
			}
			let dataJson = {
				dmgCode: this.$store.state.macCode,
				IspDate: this.tempDateSelect
			}
			let res = await getThckDeterminator(dataJson);

			if (res.data.code != 0) {
				this.Aco = {
					accOpeFile: '',
					accOpeMemb: '',
					accOpeMemo: '',
				}
				this.AcoClone = _.cloneDeep(this.Aco);
				return
			}
			this.Aco = res.data.data[0];
			this.AcoClone = _.cloneDeep(this.Aco);

		},
		//上下切换按钮
		onUpArrowClick(inAct) {

			//初始监听状态
			eventBus.$emit('getBasicStyleCompontensCurrent_EventBus');	//	基本仕样

			let Fn = () => {
				console.log("上下切换按钮", inAct)
				eventBus.$emit("onChangeSelectClick", inAct);
			}
			/**
			 * 2。  记录当前函数。
			 */
			if (this.$store.state.isCurrentNext) {
				Fn();
			} else {
				/**
				  * 4-1。   记录原来该运行的函数。
				  * 4-2。   执行保存弹出框操作。   
				  */
				this.$store.commit("changeIsCurrentFn", Fn);

				eventBus.$emit('EventBusBasicStyleCompontensSaveFn');	//	基本仕样
			}

		}
	},
	created() {
		this.temp_Date = '';
		// let that = this;
		// this.$nextTick(function () {
		//   let heightStyle = $(".right-cps-view").height() - 156;
		//   that.tableHeight = heightStyle;
		// });
	},
	mounted() {
		this.getThckDeterResComboxApi();
		this.getThckDeterResApi();
	},
	beforeDestroy() { },
	destroyed() { },
};
</script>

<style lang="scss" scoped>
.tabs-cps-view {
	width: 100%;

	.title {
		width: 100%;
		height: 32px;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 12px;



		.add-btn {
			height: 32px;
			background: #106ebe;
			color: #fff;
			border-radius: 4px;
		}

		.item {
			// width: 48%;
			display: flex;
			justify-content: flex-start;

			.label {
				width: 70px;
				display: flex;
				align-items: center;
			}

			.strat-view {
				width: calc(100% - 75px);
				display: flex;
				align-items: center;
				justify-content: space-between;
			}
		}

		.flex-ipt-view {
			width: 340px;
			height: 32px;
			display: flex;
			align-items: center;
			justify-content: flex-start;

			button {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 32px;
				height: 32px;
				// border: 1px solid #d9d9d9;
				margin-left: 8px;
				border-radius: 4px;
				font-size: 18px;
			}
		}

		.ipt {
			// width: 238px;
			height: 32px;

			::v-deep .el-input__inner {
				width: 238px;
				height: 32px;
			}

			::v-deep .el-input__inner:focus {
				border: 1px solid #dcdfe6;
			}

			::v-deep .el-input__icon {
				line-height: 32px;
				color: #909399;
			}

			::v-deep .el-input__suffix {
				width: 32px;
				right: 0;
				background: #dee0e3;
			}
		}

		.mini-select {
			margin: 0 8px;

			::v-deep .el-input__inner {
				width: 120px;
				height: 24px;
			}

			::v-deep .el-input__icon {
				line-height: 24px;
				color: #909399;
			}
		}

		.small-ipt {
			width: 180px;

			::v-deep .el-input__inner {
				width: 100%;
				height: 32px;
			}
		}

		.mini-ipt {
			width: 48px;

			::v-deep .el-input__inner {
				width: 100%;
				height: 32px;
				padding: 0;
				text-align: center;
			}
		}

		.yellow {
			::v-deep .el-input__inner {
				background: #ceedf4;
			}
		}
	}

	.row {
		display: flex;
		justify-content: space-between;
		padding-bottom: 12px;

		.item {
			width: 48%;
			display: flex;
			justify-content: flex-start;

			.label {
				min-width: 75px;
				display: flex;
				align-items: center;
			}

			.strat-view {
				width: calc(100% - 75px);
				display: flex;
				align-items: center;
				justify-content: space-between;
			}

			.ipt {
				width: 238px;
				height: 32px;

				::v-deep .el-input__inner {
					width: 238px;
					height: 32px;
				}

				::v-deep .el-input__inner:focus {
					border: 1px solid #dcdfe6;
				}

				::v-deep .el-input__icon {
					line-height: 32px;
					color: #909399;
				}

				::v-deep .el-input__suffix {
					width: 32px;
					right: 0;
					background: #dee0e3;
				}
			}
		}

		.long-item {
			width: 100%;

			// display: flex;
			// justify-content: space-around;
			.long-ipt {
				width: calc(100% - 75px);

				::v-deep .el-input__inner {
					width: 100%;
					height: 32px;
				}
			}
		}

		.last-item {
			width: calc(100% - 75px);
			display: flex;
			justify-content: space-between;
			transform: translateX(75px);

			.flex-item {
				// background-color: red;
				display: flex;
				align-items: center;
				height: 47%;
			}

			.long-ipt {
				width: 30%;
				padding: 0 10px;

				::v-deep .el-input__inner {
					width: 100%;
					height: 32px;
				}
			}

			.last-box {
				// background-color: green;
				width: 220px;

				div {
					display: flex;
					justify-content: space-between;
					align-items: center;
				}

				::v-deep .el-input__inner {
					width: 80px;
					height: 32px;
					text-align: right;
				}
			}

			.t10 {
				margin-top: 10px;
			}
		}

		.mini-select {
			margin: 0 8px;

			::v-deep .el-input__inner {
				width: 120px;
				height: 24px;
			}

			::v-deep .el-input__icon {
				line-height: 24px;
				color: #909399;
			}
		}
	}
}

.yellow {

	::v-deep .el-input__inner {
		background: #ffffe1;
	}
}

.tabYellow {
	background: #ffffe1;

	::v-deep .el-input__inner {
		background: #ffffe1;
	}
}

.orange {

	background: #FEDDB1;

	::v-deep .el-input__inner {
		background: #FEDDB1;
	}
}

.hide_input {
	position: relative !important;
}

.hide_input .el-date-editor {
	position: absolute; //绝対定位
	top: 0;
	left: 0;
	opacity: 0; //设置完全透明
}

.table-input {
	::v-deep .el-input__inner {
		background: none;
		border: 0 none;
		padding: 0;
		text-align: right;
	}
}

.table-input-center {
	::v-deep .el-input__inner {
		background: none;
		border: 0 none;
		padding: 0;
		text-align: right;
	}
}

::v-deep .el-picker-panel__body-wrapper span {
	padding-top: 2px;
}

.picker {
	width: 130px;
	height: 24px;
	margin-left: 6px;

	::v-deep .el-input__inner {
		// width: 120px;
		height: 24px;
		padding-right: 5px;
		padding-left: 20px;
	}

	::v-deep .el-input__icon {
		line-height: 24px !important;
	}

	::v-deep .el-input__prefix {
		left: 0;
	}
}

.r-describe {
	display: flex;
	align-items: center;

	.black-btn {
		padding: 0 8px;
		height: 32px;
		font-size: 14px;
		color: rgba(0, 0, 0, 0.65);
		border-radius: 4px;
		font-weight: 500;
		margin: 0 8px;
		border: 1px solid #d9d9d9;
		display: flex;
		align-items: center;

		span {
			margin: 0 0 0 8px;
		}
	}

	.black-btn1 {
		padding: 0 8px;
		height: 32px;
		// font-size: 14px;
		// color: rgba(0, 0, 0, 0.65);
		// border-radius: 4px;
		// font-weight: 500;
		// margin: 0 8px;
		// border: 1px solid #d9d9d9;
		// display: flex;
		// align-items: center;

		// span {
		// 	margin: 0 0 0 8px;
		// }
	}

	.el-icon-upload2,
	.el-icon-download,
	.el-icon-delete-solid,
	.el-icon-refresh {
		font-size: 24px;
		margin: 0 8px;
		cursor: pointer;
	}
}

.sco {
	width: 100%;
	overflow: scroll;
	height: 350px;
	padding-bottom: 150px;
	padding-right: 10px;
}
</style>
